package com.hdjk.view.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateUtil {

	public static boolean isMobileNO(String mobiles) {
		Pattern p = Pattern
				.compile("^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$");
		Matcher m = p.matcher(mobiles);

		return m.matches();
	}


	/**
	 * 判断是验证码格式
	 * 
	 * @param pValue
	 * @return
	 */
	public static Boolean isVariableCode(String pValue) {
		Pattern p = Pattern
				.compile("[0-9]{4}");
		Matcher m = p.matcher(pValue);

		return m.matches();
	}


	/**
	 * 验证是否是字母，数字，或中文
	 * @param pValue
	 * @return
     */
	public static boolean isWordNumChina(String pValue){
		Pattern p = Pattern.compile("[a-zA-Z0-9\u4e00-\u9fa5]+");
		Matcher m = p.matcher(pValue);
		return m.matches();
	}

	/**
	 * 验证是否是字母，数字
	 * @param pValue
	 * @return
	 */
	public static boolean isWordNum(String pValue) {
		char[] chars = pValue.toCharArray();
		for(int i = 0; i < chars.length; i++){
//			if((chars[i] >= 65 && chars[i] <= 90) || (chars[i] >= 97 && chars[i] <=122)){
//			}else if(chars[i] >= 48 && chars[i] <= 57){
//			}else{
//				return false;
//			}
			if (chars[i]<48||(chars[i]>57&&chars[i]<65)||(chars[i]>90&&chars[i]<97)||chars[i]>122){
				return false;
			}
		}
		return true;
	}
}
